package com.yunhe.common.mybatis.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @ClassName QueryCondition
 * @Description 输入分页等查询条件
 * @Author HeTao
 * @Date 2020/10/29 9:12
 * @Version 1.0
 **/
@ApiModel("分页实体")
@JsonIgnoreProperties(ignoreUnknown = true)
public class QueryCondition implements Serializable {

    private static final long serialVersionUID = 7496015033379793286L;

    @ApiModelProperty(value="当前页数",required=true)
    @NotNull(message="当前页数不能为空")
    private Integer page=1;// 当前页数

    @NotNull(message="每页显示条数不能为空")
    @ApiModelProperty(value="每页显示条数",required=true)
    private Integer size=10;// 每页显示条数

    @ApiModelProperty(value="开始行",hidden=true)
    private Integer startRow;// 开始行(=pageSize*(currentPageNum-1) 自动计算)


    @ApiModelProperty(value= "是否分页",hidden=true)
    private boolean pageFlag=false;

    @ApiModelProperty(value= "总条数",hidden=true)
    private Integer totalRow;

    public Integer getStartRow() {
        return startRow;
    }
    /**自动计算开始行数*/
    public void setStartRow() {
        if(page!=null&&size!=null){
            this.startRow = size*(page-1);
        }
    }

    public Integer getPage() {
        return page;
    }
    public void setPage(Integer page) {
        this.page = page;
        setStartRow();
    }
    public Integer getSize() {
        return size;
    }
    public void setSize(Integer size) {
        this.size = size;
        setStartRow();
    }

    public boolean getPageFlag() {
        return pageFlag;
    }
    public void setPageFlag(boolean pageFlag) {
        this.pageFlag = pageFlag;
    }
    public Integer getTotalRow() {
        return totalRow;
    }
    public void setTotalRow(Integer totalRow) {
        this.totalRow = totalRow;
    }
}
